using System.Diagnostics;
using System.Runtime.CompilerServices;
using UnityEngine;

public class RewardedAds : MonoBehaviour
{
	public GameObject button;

	private void Start()
	{
		if ((bool)button)
		{
			button.SetActive(IsPreloaded());
		}
		if (!IsPreloaded())
		{
			Preload();
		}
	}

	private void OnEnable()
	{
		Start();
	}

	public bool IsPreloaded()
	{
		return JavaMessageHandler.rewardedInterstitialPreloaded;
	}

	[DebuggerStepThrough]
	[AsyncStateMachine(typeof(_003CPreloadDelayed_003Ec__async0))]
	public void PreloadDelayed(float delay)
	{
		_003CPreloadDelayed_003Ec__async0 stateMachine = default(_003CPreloadDelayed_003Ec__async0);
		stateMachine.delay = delay;
		stateMachine._0024this = this;
		stateMachine._0024builder = AsyncVoidMethodBuilder.Create();
		stateMachine._0024builder.Start(ref stateMachine);
	}

	public void Preload()
	{
		if (!JavaMessageHandler.rewardedInterstitialPreloaded)
		{
			AdvertisementHandler.PreloadRewardedInterstitial();
		}
	}

	public void ShowAd()
	{
		if ((bool)button)
		{
			button.SetActive(value: false);
		}
		AdvertisementHandler.ShowPreloadedInterstitial(rewarded: true);
		JavaMessageHandler.rewardedInterstitialPreloaded = false;
		AdvertisementHandler.lastTime += 10f;
		PreloadDelayed(1f);
	}
}
